Function Reference

FileCreateShortcut

Creates a shortcut (.lnk) to a file.

FileCreateShortcut ( "file", "lnk" [, "workdir" [, "args" [, "desc" [, "icon" [, "hotkey" [, icon number [, state]]]]]]] )

 

Parameters

file Full path and file name of file to create shortcut to.
lnk Full path and file name of the shortcut.
workdir [optional] Working directory.
args [optional] Additional file arguments.
desc [optional] File Description.
icon [optional] Full Path/File name of icon to use.
hotkey [optional] Hotkey - same as the Send() key format.
icon number [optional] The icon instance to use (usually 0)
state [optional] The state the shortcut is launched in. Use either @SW_SHOWNORMAL, @SW_SHOWMINNOACTIVE or @SW_SHOWMAXIMIZED

 

Return Value

Success: Returns 1.
Failure: Returns 0 if lnk cannot be created.

 

Remarks

Hotkeys for windows shortcuts are of the following form: Ctrl+Alt+X, Ctrl+Shift+X, Shift+Alt+X, Ctrl+NumPadKey, or Alt+NumPadKey where X represents a letter, number, punctuation, or function key. If you specify an invalid form, Windows typically defaults to Ctrl+Alt
Note that Windows distinguishes number pad keys from regular number and punctuation keys. FileCreateShortcut allows you to create Ctrl+X and Alt+X shortcuts (which Windows normally only allows when X is a NumPadKey); however, you should avoid these assignments as they may conflict with standard application hotkeys.
Windows prohibits ESC, ENTER, TAB, SPACEBAR, PRINT SCREEN, SHIFT, or BACKSPACE from being used in hotkeys.

FileCreateShortcut does not require a valid target, workdir, icon, or hotkey in order to "successfully" create the LNK file; however, the destination of the LNK file must be valid! If the hotkey you choose is already in use, your new shortcut takes precedence. Also, if you create a shortcut with the same path\name as as a pre-existing shortcut, it gets overwritten with your new version.

 

Related

FileGetShortcut

 

Example


; Sets a shortcut with ctrl+alt+t hotkey
FileCreateShortcut(@WindowsDir & "\Explorer.exe",@DesktopDir & "\Shortcut Test.lnk",@WindowsDir,"/e,c:\", "This is an Explorer link;-)", @SystemDir & "\shell32.dll", "^!t", "15", @SW_MINIMIZE)